package com.macro.mall.model;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * ti_training_sourse_video实体类
 *
 * @author gaodx
 *
 */
@Data
@ApiModel(description = "课程目录报文",value = "课程目录报文")
public class TiTrainingSourseVideo implements Serializable{
	/***/
    @ApiModelProperty(value = "")
	private Integer id; 
	/**专题id*/
    @NotNull(message = "专题id不可为空")
    @ApiModelProperty(value = "专题id")
	private Integer training; 
	/**名称*/
    @NotNull(message = "名称不可为空")
    @ApiModelProperty(value = "名称")
	private String name; 
	/***/
    @ApiModelProperty(value = "")
	private Date createTime; 
	/***/
	@JsonInclude(JsonInclude.Include.NON_NULL)
    @ApiModelProperty(value = "")
	private String videoCount;

	/***/
    @ApiModelProperty(value = "视频列表")
	private List<TiTrainingVideo> videoList;
	/**
	 * 实例化
	 */
	public TiTrainingSourseVideo() {
		super();
	}
	/**
	 * 实例化
	 * 
	 * @param obj
	 */

	public TiTrainingSourseVideo(JSONObject obj) {
		this();
		if (obj.get("id") instanceof Number) {
			this.setId(((Number) obj.get("id")).intValue());
		}
		if (obj.get("training") instanceof Number) {
			this.setTraining(((Number) obj.get("training")).intValue());
		}
		if (obj.get("name") instanceof String) {
			this.setName((String) obj.get("name"));
		}
		this.setCreateTime((Date) obj.get("createTime"));
	}
	
	/**
	 * 将当前对象转换为JsonObject
	 * 
	 * @return
	 */
	public JSONObject toJson() {
		JSONObject result = new JSONObject();
		if (this.getId() != null) {
			result.put("id",this.getId());
		}
		if (this.getTraining() != null) {
			result.put("training",this.getTraining());
		}
		if (this.getName() != null) {
			result.put("name",this.getName());
		}
		if (this.getCreateTime() != null) {
			result.put("createTime",this.getCreateTime());
		}
		return result;
	}


	@Override
	public String toString() {
		return "TiTrainingSourseVideo [id=" + id + " , training=" + training + " , name=" + name + " , createTime=" + createTime + "  ]";
	
	}
	
	
}
